package com.example.blog.config;

import com.example.blog.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.resource.NoResourceFoundException;

@RestControllerAdvice
@Slf4j

public class ExceptionAdvice {
    @ExceptionHandler
    public Result handle(Exception e){
        log.error("发送异常："+e.getMessage());
        return Result.fail("发生异常请联系管理员");
    }

    @ExceptionHandler
    public Result handle(NoResourceFoundException e){
        log.error("发送异常："+e.getMessage());
        return Result.fail("找不到内部资源,请联系管理员");
    }
}
